package com.apexsoft.front.common.utils;

import java.lang.reflect.Method;

public class BeanMethodUtil {
	
	public static String getGetMethod(String columnName)
	{
		String[] ss = columnName.toLowerCase().split("_");
		StringBuffer sb = new StringBuffer();
		sb.append("get");
		for(int i=0;i<ss.length;i++)
		{
			sb.append(ss[i].substring(0,1).toUpperCase()+ss[i].substring(1));
		}
		return sb.toString();
	}
	
	public static String getSetMethod(String columnName)
	{
		String[] ss = columnName.toLowerCase().split("_");
		StringBuffer sb = new StringBuffer();
		sb.append("set");
		for(int i=0;i<ss.length;i++)
		{
			sb.append(ss[i].substring(0,1).toUpperCase()+ss[i].substring(1));
		}
		return sb.toString();
	}
	
	public static boolean hasMethod(Object o,String method)
	{
		if(method==null)return false;
		Method[] methods = o.getClass().getMethods();
		for(Method m:methods)
		{
			if(method.equals(m.getName()))
				return true;	
		}
		return false;
	}
	

}
